package entity

import (
	"github.com/crack007/go-im/src/common/util"
)

type MessageEntity struct {
	ID         uint32 `gorm:"column:id;primary_key" json:"id"`         //
	SessionID  uint64 `gorm:"column:session_id" json:"session_id"`     //
	FromUID    uint32 `gorm:"column:from_uid" json:"from_uid"`         //发送者uid
	ToUID      uint32 `gorm:"column:to_uid" json:"to_uid"`             //接收者uid
	ToUserType uint8  `gorm:"column:to_user_type" json:"to_user_type"` //接收用户类型
	ReadStatus uint8  `gorm:"column:read_status" json:"read_status"`   //已读状态(0-未读,1-已读)
	MsgType    uint8  `gorm:"column:msg_type" json:"msg_type"`         //内容类型
	IsDelete   bool   `gorm:"column:is_delete" json:"is_delete"`       //是否删除(0-正常,1-已删除)
	Message    string `gorm:"column:message" json:"message"`           //消息内容
	CreatedAt  string `gorm:"column:created_at" json:"created_at"`     //
	UpdatedAt  string `gorm:"column:updated_at" json:"updated_at"`     //
}

// TableName sets the insert table name for this struct type
func (i *MessageEntity) TableName() string {
	return "im_message"
}

func NewMessageEntity() *MessageEntity {
	return &MessageEntity{
		CreatedAt: util.GetDatetime(),
		IsDelete:  false,
	}
}
